<template>
    <div class="project-edit contain-edit">
        <div class="header">
           <p>项目管理>>添加</p>
        </div>
       <div class="main">
           <el-form :model="information" :rules="rules" ref="information" label-width="120px" class="">
               <el-form-item label="关于我们：" prop="content">
                    <bg-editor 
                        :minHeight="200" 
                        :minWidth="680"
                        :uploadUrl="upLoadUrl" 
                        :content="information.content"
                        @editorData='editorInfo'>
                    </bg-editor>
                </el-form-item>   
                <el-form-item>
                    <el-button type="primary" @click="submitForm('information')"  :loading="loading">保存</el-button>
                </el-form-item>
           </el-form>
       </div>

    </div>
</template>

<script>
let CONSTANT = require('../../constant/constant.js');
let common = require("../../common.js");
import $ from 'jquery'
import $axios from 'axios'
  export default {
    data() {
        return {
            upLoadUrl:"",
            loading:false,
            information:{
                content :'DD',
            },
            rules: {
                content: [
                    { required: true, message: '请输入内容', trigger: 'blur' }
                ],
            },
        };
    },
    components:{
         'bg-editor':()=>import('../common/bg-editor.vue')
    },
    watch:{
    },
    mounted() {
        this.getDetail(); 
    },
    methods: {
        editorInfo(val){
            this.information.content = val;
        },
         getDetail(id){
            let url = CONSTANT.URL.SYSVAR.FINDPLATABOUTDETAIL;
            let param = {
                id:id
            };
            common.requestAjax(url,{},param,(res)=>{
                let info = res.data.bussData;
                this.information ={
                    content:info
                }
            })
        },
        submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.loading = true;
                    var url = CONSTANT.URL.SYSVAR.SAVEPLATABOUT;
                    common.requestAjax(url, {}, this.information, res => {
                        if(res.status == 200) {
                            this.$message({
                                type: 'success',
                                message: '保存成功!'
                            });
                            this.loading = false;
                        } else {
                            this.$message({
                                type: 'error',
                                message: res.msg
                            });
                            this.loading = false;
                        }
                    });
                } else {
                    return false;
                }
            });
        },
    }
  }
</script>

<style lang="scss" >
@import '/static/bootstrap.css';     
@import '/sys/static/bootstrap.css'; 
    .el-form-item__content{
        margin-left: 0;
    }
    .project-edit{
        .el-form-item__label{
            font-size: 13px!important;
        }
    }
</style>